home *** CD-ROM | disk | FTP | other *** search
/ Night Owl - The Best of BBS / Night Owl The Best of BBS (NOP-BBS) (Night Owl Publisher) (1994).iso / 014a / ezbbs215.lha / Source / eazy2mail_direct.c next >
C/C++ Source or Header  |  1994-02-06  |  2KB  |  94 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <time.h>
  5. #include <proto/dos.h>
  6. #include <proto/exec.h>
  7.  
  8.  
  9.  
  10. #define VERSION "1.7"
  11. static char *version = "\0$VER: eazy2mail "VERSION" ("__AMIGADATE__")";
  12.  
  13.  
  14.  
  15. void space2under(char *s)
  16. {
  17.   while (s && *s) {
  18.     if (*s==' ')
  19.       *s = '_';
  20.     s++;
  21.   }
  22. }
  23.  
  24.  
  25.  
  26. int main(int argc, char *argv[])
  27. {
  28.   if (argc==6) {
  29.     char tmp[80];
  30.     FILE *fp;
  31.  
  32.     sprintf(tmp,"%s%ld","MB_TMP:Eazy2Mail.tmp",(long)FindTask(NULL));
  33.  
  34.     if (fp=fopen(tmp,"w")) {
  35.       register int c=0,last=0;
  36.       time_t t;
  37.       struct tm *ut;
  38.       char uname[16];
  39.       char *sname = argv[2];
  40.       char *tonam = argv[4];
  41.       char *realn = argv[3];
  42.       char *sbjct = argv[5];
  43.       char exec[256];
  44.  
  45.       time(&t);
  46.       ut = gmtime(&t);
  47.  
  48.       strcpy(uname,argv[1]);
  49.       space2under(uname);
  50.  
  51.       fprintf(fp,"From: %s@%s (%s)\n",uname,sname,realn);
  52.       fprintf(fp,"To: %s\n",tonam);
  53.       fprintf(fp,"Sender: eazybbs@%s\n",sname);
  54.       fprintf(fp,"Subject: %s\n",sbjct);
  55.       fprintf(fp,"MIME-Version: 1.0\n");
  56.       fprintf(fp,"Content-Type: text/plain; charset=ISO-8859-1\n");
  57.       fprintf(fp,"Content-Transfer-Encoding: 8bit\n");
  58.       fprintf(fp,"\n");
  59.  
  60.       while ((c=getchar())!=EOF) {
  61.         if (last=='\\') {
  62.           switch (c) {
  63.           case '\\': fputc(c,fp);
  64.                      break;
  65.           default  : break;
  66.           }
  67.           last = 0;
  68.         }
  69.         else if (c=='\\') {
  70.           last = c;
  71.         }
  72.         else {
  73.           fputc(c,fp);
  74.           last = c;
  75.         }
  76.       }
  77.       fprintf(fp,"\n");
  78.  
  79.       fclose(fp);
  80.  
  81.       sprintf(exec,"sendmail <%s",tmp);
  82.       System(exec,NULL);
  83.       DeleteFile(tmp);
  84.     }
  85.   }
  86.   else {
  87.     fprintf(stderr,"\033[1;33mEazyBBS\033[0m ⌐ 1988-1993 Andreas M. Kirchwitz\n"
  88.                    "Usage: eazy2mail \033[3m<user> <site> <real> <to> <subject> \033[0m <text\n");
  89.   }
  90.  
  91.   exit(0);
  92. }
  93.  
  94.